Skip to content

Merge esp-rs/esp-hal main into feature/ble-host-npl-upstream - #3

Merged
Lakier15 merged 229 commits into
feature/ble-host-npl-upstreamfrom
wasilij/merge-upstream-main
Nov 4, 2026
Merged

Lakier15 merged 229 commits into
feature/ble-host-npl-upstreamfrom
wasilij/merge-upstream-main

Conversation

@collapsinghierarchy

@collapsinghierarchy collapsinghierarchy commented Oct 29, 2026 •

Copy link
Copy Markdown

What

Merges esp-rs/esp-hal main (up to 5c0820c) into feature/ble-host-npl-upstream. Our fork-only work (BLE NPL host, internal-RAM NPL memory, C5/C61 PSRAM fix) stays on top.

Fork-only diff: esp-rs/esp-hal@5c0820c...peeriot:esp-hal:wasilij/merge-upstream-main

Our changes on this branch

  • b562c20e, the merge. Upstream moved ble/npl.rs to ble/npl/mod.rs and added os_mempool, lp_clk and btdm2. We kept upstream's layout and ported our NPL host additions onto it: the ble-host-npl feature, the exported NPL symbols, malloc_internal/calloc_internal, and the HCI buffer handling.
  • 6fbb1595, 321c55d2: keep npl::send_hci public behind ble-host-npl. Upstream made it crate-private, and esp-nimble-host calls it.
  • 135a52ae: os_memblock_get clears the free-list link in a block's first word before handing it out. Without this, the NimBLE host crashes on C5 and C61 (see below).
  • 87a9b4e2 and its revert e7b8b369: a first attempt that left os_mempool to esp-nimble-host. The new controller blob needs os_mempool_flags_set and os_ext_mempool_register_cb from upstream's pool, so it did not link.

HIL validation

swarm-ci run 41040958588 on peeriot/swarm wasilij/esp-hal-upstream-bump (fe37db6b, the same tree as this branch's head before the merge commit message was reworded): C5, C6, C61, the C6 signal layer, and BLE on C5 and C61. Result: all jobs pass. One flaky test: on C5, notifications_count_up_until_unsubscribed got counter value 2 as its first notification on tries 1 and 2 (expected 1), then passed on try 3.

Changes the swarm needs (as in the validation run)

Implemented in peeriot/swarm#1672 (private).

  • Cargo.toml:
    • the nine esp-* crates on branch wasilij/merge-upstream-main;
    • esp32c5/esp32c61 on the PAC source esp-hal uses, { version = "0.4"/"0.5", git = "https://github.com/esp-rs/esp-pacs.git", rev = "5cb8c50" } (deny.toml bans two versions of a PAC);
    • esp-nimble-host on branch wasilij/esp-hal-merge-upstream-main (125a9be), which points esp-hal/esp-radio at this branch.
  • esp-firmware and esp-firmware-macros: esp_rtos::start(timer0), because the FROM_CPU_INTR0 argument is gone.
  • Cargo.lock: relock the esp crates only. A broad relock moved spareval to sha2 0.10 and broke the host build, so keep the other crates' entries as on master.

Known issue: NPL event initialisation

ble_npl_event_init (esp-radio/src/ble/npl/mod.rs) treats a non-zero ble_npl_event.dummy as "already initialised" and then skips setting the callback. NimBLE recycles event blocks from a pool that keeps its free-list pointer in exactly that word. A reused block therefore looked initialised, and the stale pointer ran as the callback: Illegal instruction in ble_hs_hci_os_event_buf.

Before the merge, esp-nimble-host's patched os_mempool.c hid this by zeroing blocks. Upstream's Rust pool now takes those symbols, and 135a52ae does the minimal part of that zeroing there.

Proper fix, as a follow-up:

  • ble_npl_event_init allocates Events from an esp-radio-owned pool, recognises them by pool membership (as ESP-IDF's NPL does), and always sets fn/arg.
  • esp-nimble-host then drops its os_mempool.c (already unlinked since 135a52ae) and the zero-on-alloc patch. The ble_hs.c patch that deinitialises events before returning them stays unless the new design frees Events another way.

Not checked

  • ESP32-C2, C3, H2 and the Xtensa chips were not built. The C2 edit is uncompiled.
  • Formatting and esp-hal's own CI and HIL (the PR is a draft, so its jobs skip).

🤖 Generated with Claude Code

MabezDev and others added 30 commits August 26, 2026 08:42
* specify version in esp-bootloader def of esp-storage

* Release 7 packages

- esp-radio-rtos-driver: 0.3.0 → 0.4.0
- esp-alloc: 0.10.0 → 0.11.0
- esp-println: 0.17.0 → 0.18.0
- esp-rtos: 0.3.0 → 0.4.0
- esp-storage: 0.9.0 → 0.10.0
- esp-backtrace: 0.19.0 → 0.20.0
- esp-bootloader-esp-idf: 0.5.0 → 0.6.0
* xtask: re-read manifests in execute-plan apply loop

The preflight loop parsed every package manifest up front and the apply
loop reused those in-memory copies. Bumping a package rewrites the
on-disk manifests of its workspace dependents, so a package bumped after
its dependencies had those rewrites on disk - but its own bump step then
saved its stale pre-bump snapshot, silently reverting them.

esp-hal is bumped last and depends on nearly every other released crate,
so it lost all of its intra-workspace dependency bumps (e.g. the
esp-config build-dependency stayed at the old requirement), which broke
the release build. Re-read each manifest from disk immediately before
bumping so dependency rewrites from earlier steps are preserved.

Regression from esp-rs#5644, which moved the manifest load into an up-front
preflight loop and reused the parsed copies.

Co-authored-by: Cursor <cursoragent@cursor.com>

* xtask: make release PR upsert idempotent

find_existing_pr can miss a just-created PR because GitHub's PR listing
lags for a moment after execute-plan force-pushes the release branch. On
a re-run the lookup returned nothing, so `gh pr create` ran a second time
and re-applied every release label and re-requested code-owner reviews,
which showed up as duplicated PR timeline entries.

Recover from `gh pr create`'s "a pull request ... already exists" error
by parsing the existing PR number and editing that PR (title and body
only) instead of bailing or opening a duplicate. Labels are still applied
exactly once, on first creation, so a maintainer removing one to skip its
optional CI check is respected.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
* Bulk-apply auto API doc improvements

* Re-add removed sentence-end periods
* Clean up

* Clear update control bit
* keep 32kHz crystal powered

* Manually keep the clock alive
* Test that the max frequency is attainable with default clock source

* Restore defaults

* Ensure high-speed PLLs are divided down
* fixup mg

* Release 3 packages

- esp-metadata-generated: 0.5.0 → 0.5.1
- esp-hal: 1.2.0-rc.0 → 1.2.0
- esp-radio-rtos-driver: 0.4.0 → 0.4.1

* fixup mg
* Enable octal PSRAM for P4

* Default to 80MHz PSRAM
* Enable I2S for ESP32-S31

* use achievable rate

* Simplify P4/S31 path cfg
* Add interrupt handling for I2S parallel peripheral

* Mark I2S parallel structures/enums and methods as unstable; add more interrupt handling functions to I2sParallelTransfer

* Refine documentation for I2S parallel interface: adhere to API-DOC-RULES

* interrupt management methods on I2sParallelTransfer should only be available in Blocking

* hil-test: i2s parallel interrupts
JurajSadel and others added 16 commits October 23, 2026 13:19
Rsa::disable_constant_time(false) turned constant time off, the
opposite of its name. The work queue called it that way, so its RSA
operations ran without constant time by default.

Replace the two setters with rsa::Config and Rsa::apply_config, as
the driver guidelines describe, and have Rsa::new take a Config.
Config::default() has constant time on and search acceleration off.
* ECC: add SM2 curve support

* ECC: report unsupported curves through OperationError
* ESP32-S3: fix Debug Assist CPU1 PC reads

* HIL: align Debug Assist test listing with module order

* HIL: run CPU0 region-monitor PC test on single-core chips

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
* WIP S3 experiment

* Query stored metrics from app-metrics API

* Minor improvements do not end up in the table

* add s3-server secret
* Fix spelling in comments, docs, and metadata generator output.

* Keep the existing useable spelling.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Reclaim the 64 KiB of boot RAM on the ESP32-S31

Before this change, #[ram(reclaimed)] and DRAM2_UNINIT_SIZE covered
only the 8 KiB of the ROM's startup stack on the ESP32-S31. The 56 KiB
below it, used by the 2nd stage bootloader and the ROM's download-mode
buffers, is also free once the application runs. Programs that sized
their heap from DRAM2_UNINIT_SIZE ran out of internal RAM, and Wi-Fi
programs panicked at boot when a thread stack could not be allocated.

The region now starts at 0x2F06_CFB0 and covers 64 KiB.

* Extend the ESP32-S31's DRAM range to the top of SRAM

The DRAM range ended at 0x2F07_AFC0, below the top 8 KiB of the
reclaimed region. The range now ends at SOC_DRAM_HIGH, 0x2F08_0000.
* set up Python step

* bump pinned python version
…-rs#6527)

* ci: store API baselines in a GitHub release instead of artifacts

* reviews
@collapsinghierarchy
collapsinghierarchy marked this pull request as ready for review October 30, 2026 11:25
@github-actions

Copy link
Copy Markdown

⚠️ Do not edit CHANGELOG.md manually

This PR modifies the following changelog file(s) directly:

  • esp-alloc/CHANGELOG.md
  • esp-backtrace/CHANGELOG.md
  • esp-bootloader-esp-idf/CHANGELOG.md
  • esp-hal/CHANGELOG.md

Changelog entries are no longer maintained by hand. Instead, add your entries to the PR description under the # Changelog section:

# Changelog

## esp-hal

- Added: Short description of the change
- Fixed: Short description of the fix

Migration guide entries go in the # Migration guide section (area is required; each breaking change needs a ### Title heading):

# Migration guide

## esp-hal/SPI

### `OldType` has been renamed to `NewType`

Replace all uses of `OldType` with `NewType`.

Please revert the changes to CHANGELOG.md and move your entries to the PR description instead.
Run cargo xtask check-pr-changelog locally to validate the format before pushing.

Keeps upstream's new BLE layout (ble/npl/mod.rs behind the `porting`
module, os_mempool, lp_clk) and ports the NPL host additions onto it: the
`ble-host-npl` feature, the exported NPL symbols, memory from internal RAM
and the HCI buffer handling.
Upstream replaced ble::npl::send_hci with the crate-private porting::send.
Keep a thin public wrapper behind the ble-host-npl feature.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
esp-nimble-host compiles NimBLE's own os_mempool.c and patches it to zero
blocks on allocation. The Rust os_mempool upstream added exports the same
symbols, the linker picked it, and recycled event blocks kept their
free-list pointer: ble_npl_event_init took it for an initialised event and
the host task jumped into ble_hs_hci_os_event_buf (HIL BLE on C5 and C61).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A recycled block kept the pool's free-list pointer in its first word.
ble_npl_event_init takes a non-zero first word for an initialised event,
so the NimBLE host ran the stale pointer as an event callback and crashed
in ble_hs_hci_os_event_buf (HIL BLE on C5 and C61). esp-nimble-host
patched its own os_mempool.c for this, but the controller blob needs this
pool (os_mempool_flags_set, os_ext_mempool_register_cb), so the fix has to
live here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@collapsinghierarchy
collapsinghierarchy force-pushed the wasilij/merge-upstream-main branch from 8cc7cc4 to 135a52a Compare October 30, 2026 11:32

@Lakier15 Lakier15 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lakier15
Lakier15 merged commit b982947 into feature/ble-host-npl-upstream Nov 4, 2026
16 of 23 checks passed
@Lakier15
Lakier15 deleted the wasilij/merge-upstream-main branch November 4, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.